package org.xydpeng.demo.grpc;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext;
import org.xydpeng.demo.grpc.service.GrpcClientService;

/**
 * @author xydpeng
 * @version v1.0
 * @date: 2023/4/19
 * @description:
 */
@EnableDiscoveryClient
@SpringBootApplication
public class ConsumerApp {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(ConsumerApp.class, args);

       final GrpcClientService clientService = context.getBean(GrpcClientService.class);

        new Thread(() -> {
            for (int i = 0; i < 20; i++) {
                String r = clientService.sendMessage("zhangsansan");
                System.out.println(r);

                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"t1").start();
    }
}
